﻿//////////////////////////////////////////////////////////////////////////
//20081212:现在都流行一遍过吗.....................
//////////////////////////////////////////////////////////////////////////
#include "cMySystem.h"

//
//int g_src_width = 0;
//int g_src_height = 0;
//
//HWND g_Wnd = 0;

cMySystem::cMySystem()
{
	this->m_wName = NULL;
	this->m_wTitle = NULL;
	this->m_Height = 0;
	this->m_Width = 0;
	this->m_PosX = 0;
	this->m_PosY = 0;
	this->m_FTime = 1000;
	this->m_LastTime = 0;

	this->m_BehaviorHandler = NULL;
	this->m_ColorList = NULL;
	this->m_FontDescs = NULL;
	this->m_Graphics = NULL;
	this->m_IdManager = NULL;
	this->m_MyVariable = NULL;
	this->m_MyWindowHandler = NULL;
	this->m_ProcessEngine = NULL;
	this->m_MessageRecorder = NULL;
	this->m_DrawMaster = NULL;

	this->m_InputDevice = NULL;

//	this->m_Tile = NULL;
	this->m_InfoUnion = NULL;
	this->m_SceneFormula = NULL;
//	this->m_EmuScript = NULL;
}

cMySystem::~cMySystem(void)
{
	if(this->m_Graphics!=NULL)
	{
		delete m_Graphics;
	}
	if(this->m_MyWindowHandler!=NULL)
	{
		delete m_MyWindowHandler;
	}
	if(this->m_ColorList!=NULL)
	{
		delete m_ColorList;
	}
	if(this->m_FontDescs!=NULL)
	{
		delete m_FontDescs;
	}
	if(this->m_IdManager!=NULL)
	{
		delete m_IdManager;
	}
	if(this->m_BehaviorHandler!=NULL)
	{
		delete m_BehaviorHandler;
	}
	if(this->m_MyVariable!=NULL)
	{
		delete m_MyVariable;
	}
	if(this->m_ProcessEngine!=NULL)
	{
		delete m_ProcessEngine;
	}
	if(this->m_Trigger!=NULL)
	{
		delete m_Trigger;
	}
	if(this->m_InputDevice!=NULL)
	{
		delete m_InputDevice;
	}
	if(this->m_Input!=NULL)
	{
		delete m_Input;
	}
	if (this->m_InfoUnion!=NULL)
	{
		delete m_InfoUnion;
	}

	if (this->m_SceneFormula!=NULL)
	{
		delete m_SceneFormula;
	}

	if (this->m_MessageRecorder!=NULL)
	{
		delete m_MessageRecorder;
	}

	if (this->m_DrawMaster != NULL)
	{
		delete m_DrawMaster;
	}

	cout<<"cMySystem deleted"<<endl;//debug
}

bool cMySystem::Init(char *wName,char *wTitle,int xPos,int yPos,int Width,int Length)
{
	WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC,
		&cMySystem::MyMsgProc, 0L, 0L,
		GetModuleHandle(NULL), NULL, NULL, NULL, NULL,(LPCSTR)wName, NULL };

	this->m_WC=wc;
	
	this->m_PosX=xPos;
	this->m_PosY=yPos;
	this->m_Width=Width;
	this->m_Height=Length;
	this->m_wName=wName;
	this->m_wTitle=wTitle;

	if(m_wName==NULL||m_wTitle==NULL)
	{
		return false;
	}

	RegisterClassEx(&this->m_WC);

	this->m_hWnd = CreateWindow((LPCSTR)m_wName, (LPCSTR)m_wTitle, 
                      WS_SYSMENU|WS_MINIMIZEBOX,m_PosX,m_PosY,m_Width,m_Height,
                      NULL,NULL,m_WC.hInstance,NULL );
	
	//g_Wnd = m_hWnd;

	RECT WndRect;
	RECT ClientRect;
	GetWindowRect(m_hWnd, &WndRect);
	GetClientRect(m_hWnd, &ClientRect);
	//实际屏幕显示的宽度
	int ScrWidth = ClientRect.right - ClientRect.left;
	//实际屏幕显示的高
	int ScrHeight = ClientRect.bottom - ClientRect.top;
//////////////////////////////////////////////////////////////////////////
	//这段代码可以使显示区显示完整的比如定义好的640×480
	//重构窗口的大小
	MoveWindow(m_hWnd,WndRect.left,WndRect.top,
		WndRect.right-WndRect.left-ClientRect.right+g_WinWidth,
		WndRect.bottom-WndRect.top-ClientRect.bottom+g_WinHeight,TRUE);

	ScrWidth = g_WinWidth;
	ScrHeight = g_WinHeight;
//////////////////////////////////////////////////////////////////////////

	this->m_Graphics=new cGraphics();
	if(false==this->m_Graphics->Init())
	{
		return false;
	}
	if(false==this->m_Graphics->SetMode(m_hWnd))
	{
		return false;
	}

	// init components
	this->m_Input = new cInput();
	this->m_Input->Init(m_hWnd,wc.hInstance);

	this->m_InputDevice = new cInputDevice();
	this->m_InputDevice->Create(m_Input,KEYBOARD);

	this->m_ColorList=new cColorList();

	this->m_FontDescs=new cFontDescs();

	this->m_IdManager=new cIdManager();

	this->m_MyVariable=new cVariableHandler();

	this->m_ProcessEngine=new cProcessEngine();

	this->m_Trigger=new cTrigger(m_ProcessEngine);

	this->m_MyWindowHandler=new cMyWindowHandler();
	this->m_MyWindowHandler->Init(m_Graphics->GetDeviceCOM(),
		m_Graphics->GetSpriteCOM(),m_IdManager,m_FontDescs,m_ColorList);

	this->m_StateHandler = new cStateHandler();

	this->m_InfoUnion = new cInfoUnion();
	this->m_InfoUnion->CameraPosX = 0;
	this->m_InfoUnion->CameraPosY = 0;
	this->m_InfoUnion->MatrixNumAxisX= 24;
	this->m_InfoUnion->MatrixNumAxisY= 24;
	this->m_InfoUnion->MatrixUnitWidth= 40;
	this->m_InfoUnion->MatrixUnitHeight= 40;
	this->m_InfoUnion->ScreamWidth = ScrWidth;
	this->m_InfoUnion->ScreamHeight = ScrHeight;
	this->m_InfoUnion->ScrMatrixNumX = ScrWidth/40;
	this->m_InfoUnion->ScrMatrixNumY = ScrHeight/40;
	this->m_InfoUnion->CursorStepDistance = 50.0f;
	this->m_InfoUnion->CursorMoveTimeMate = 0.0f;
	this->m_InfoUnion->CharacterStepDistance = 5.0f;
	this->m_InfoUnion->CharacterMoveTimeMate = 50.0f;

	this->m_MessageRecorder = new cMessageRecorder();
	this->m_DrawMaster = new cDrawMaster();

	this->m_SceneFormula = new cSceneFormula();
	this->m_SceneFormula->Init(m_InputDevice,m_Graphics,
		m_FontDescs,m_InfoUnion,m_MessageRecorder,m_DrawMaster);

	this->m_BehaviorHandler=new cBehaviorHandler();
	this->m_BehaviorHandler->Init(m_ColorList,m_FontDescs,m_IdManager,
		m_InputDevice,m_MyWindowHandler,m_Trigger,m_ProcessEngine,m_MyVariable,
		m_StateHandler,m_SceneFormula,m_Graphics,m_MessageRecorder,m_DrawMaster);

	
//	m_Map.UseTiles(&m_Tile);
	
	return true;
}


LRESULT WINAPI cMySystem::MyMsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch( msg )
    {
        case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;

    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}

bool cMySystem::Run()
{
	ShowWindow(m_hWnd,SW_SHOWDEFAULT);
	UpdateWindow(m_hWnd);

	if(this->SetResourse()==true)
	{
		MSG msg; 
		ZeroMemory( &msg, sizeof(msg) );
		while( msg.message!=WM_QUIT )
		{
		   if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
		   {
			   TranslateMessage( &msg );
			   DispatchMessage( &msg );
		   }
		   else
		   {
			   this->Render();
		   }
		}
	}
	UnregisterClass( (LPCSTR)this->m_wName, m_WC.hInstance );

	return true;
}

bool cMySystem::SetResourse()
{
	cAnimation *CursorAnime = new cAnimation(m_Graphics);
	CursorAnime->BuildTextureQueue(1);
	CursorAnime->LoadTexture(0,"Data\\pic\\游标\\MyCursorOne.bmp",D3DCOLOR_RGBA(255,255,255,255));
	CursorAnime->BuildAnimeSorceQueue(1);
	CursorAnime->LoadAnimeSorce(0,0,0,0,40,40);
	CursorAnime->SetAlphaTransColour(D3DCOLOR_RGBA(255,255,255,255));
	m_SceneFormula->m_Cursor->Init(4,4,CursorAnime);
	//---------------------------------------------------------------------------------

	m_SceneFormula->GetMap()->ReadDataFile("Data\\Map\\Map1.dat");
	m_SceneFormula->GetMap()->SetIfShow(true);

	//-----------------------------------------------------------------------------------------
	int A = 1 , B = 2, C = 3, E = 100;

	int BlockData[22][18] = { 
		{ E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E, E },
		{ E, E, A, E, E, A, E, E, A, E, E, A, E, E, E, E, E, E },
		{ E, E, A, E, E, A, E, E, A, E, E, A, E, E, E, E, E, E },
		{ A, A, A, A, A, A, A, A, A, A, A, A, A, A, E, E, E, E },
		{ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, E },
		{ E, A, E, A, A, A, A, A, A, A, A, A, A, A, A, A, A, E },
		{ E, E, E, E, A, A, A, A, E, E, A, A, A, A, A, A, A, E },
		{ E, E, E, E, A, A, E, A, E, E, A, A, A, A, A, A, A, E },
		{ A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, A, E, E },
		{ E, A, A, E, A, A, A, A, A, A, A, A, A, A, A, A, E, E },
		{ E, A, A, E, A, A, A, A, A, A, A, A, A, A, A, A, E, A },
		{ E, A, A, E, A, A, E, E, E, A, A, A, A, A, A, A, E, A },
		{ A, A, A, A, A, A, E, E, E, A, A, A, A, A, A, A, E, A },
		{ A, A, A, A, A, A, E, E, E, A, E, E, E, E, A, A, E, A },
		{ A, A, A, A, A, A, E, E, E, A, E, E, E, E, A, A, E, A },
		{ A, A, A, A, A, A, E, E, E, A, E, E, E, E, A, A, E, A },
		{ A, A, A, A, A, A, A, A, A, A, E, E, E, E, E, E, E, A },
		{ A, A, A, A, A, E, E, E, E, E, E, E, E, E, E, E, E, A },
		{ A, A, A, A, A, E, E, E, E, E, A, A, A, A, A, A, A, A },
		{ A, A, A, A, A, E, E, E, E, E, A, A, A, A, A, A, A, A },
		{ A, A, A, A, A, E, E, E, E, E, A, A, A, A, A, A, A, A },
		{ E, E, E, E, E, E, E, E, E, E, A, A, A, A, A, A, A, A },
	};

	cBlockHandler *BlockHandler = m_SceneFormula->GetBlockHandler();
	BlockHandler->BuildBlockData((int*)&BlockData,22,18);

	//--------------------------------------------------------------------------------------------
	cAnimation *CureAnime = new cAnimation(m_Graphics);
	CureAnime->SetAlphaTransColour(D3DCOLOR_RGBA(255,255,255,200));
	CureAnime->BuildTextureQueue(1);
	CureAnime->LoadTexture(0,"Data\\pic\\Magics\\治疗魔法\\CureMix.png",D3DCOLOR_RGBA(34,34,194,255));
	CureAnime->BuildAnimeSorceQueue(8);
	CureAnime->LoadAnimeSorce(0,0,54*0,54*0,54,54,100);
	CureAnime->LoadAnimeSorce(1,0,54*1,54*0,54,54,100);
	CureAnime->LoadAnimeSorce(2,0,54*2,54*0,54,54,100);
	CureAnime->LoadAnimeSorce(3,0,54*0,54*1,54,54,100);
	CureAnime->LoadAnimeSorce(4,0,54*1,54*1,54,54,100);
	CureAnime->LoadAnimeSorce(5,0,54*2,54*1,54,54,100);
	CureAnime->LoadAnimeSorce(6,0,54*0,54*2,54,54,100);
	CureAnime->LoadAnimeSorce(7,0,54*1,54*2,54,54,100);

	cMagicHandler *MagicHandler = m_SceneFormula->GetMagicHandler();
	cMagicDescription *MagicCure = new cMagicDescription();
	MagicCure->m_MagicID = "治疗术";
	MagicCure->m_MagicName = "治疗术";
	MagicCure->m_CastTarget = CT_CasterAndFriend;
	MagicCure->m_CastEffect	= CE_UpHP;
	MagicCure->m_CastRange = 2;
	MagicCure->m_EffectValue = 10;
	MagicCure->m_Detail = "回复一定的HP";
	MagicCure->m_CastingAnimationTarget = CAT_SelectedTarget;
	MagicCure->m_Animation = CureAnime;

	cAnimation *FireAnime = new cAnimation(m_Graphics);
	FireAnime->SetAlphaTransColour(D3DCOLOR_RGBA(255,255,255,200));
	FireAnime->BuildTextureQueue(1);
	FireAnime->LoadTexture(0,"Data\\pic\\Magics\\火焰魔法\\FireMix.png",D3DCOLOR_RGBA(40,0,0,255));
	FireAnime->BuildAnimeSorceQueue(16);
	FireAnime->LoadAnimeSorce(0,0,128*0,128*0,128,128,100);
	FireAnime->LoadAnimeSorce(1,0,128*1,128*0,128,128,100);
	FireAnime->LoadAnimeSorce(2,0,128*2,128*0,128,128,100);
	FireAnime->LoadAnimeSorce(3,0,128*3,128*0,128,128,100);
	FireAnime->LoadAnimeSorce(4,0,128*0,128*1,128,128,100);
	FireAnime->LoadAnimeSorce(5,0,128*1,128*1,128,128,100);
	FireAnime->LoadAnimeSorce(6,0,128*2,128*1,128,128,100);
	FireAnime->LoadAnimeSorce(7,0,128*3,128*1,128,128,100);
	FireAnime->LoadAnimeSorce(8,0,128*0,128*2,128,128,100);
	FireAnime->LoadAnimeSorce(9,0,128*1,128*2,128,128,100);
	FireAnime->LoadAnimeSorce(10,0,128*2,128*2,128,128,100);
	FireAnime->LoadAnimeSorce(11,0,128*3,128*2,128,128,100);
	FireAnime->LoadAnimeSorce(12,0,128*0,128*3,128,128,100);
	FireAnime->LoadAnimeSorce(13,0,128*1,128*3,128,128,100);
	FireAnime->LoadAnimeSorce(14,0,128*2,128*3,128,128,100);
	FireAnime->LoadAnimeSorce(15,0,128*3,128*3,128,128,100);

	cMagicDescription *MagicFireBall = new cMagicDescription();
	MagicFireBall->m_MagicID = "火球术";
	MagicFireBall->m_MagicName = "火球术";
	MagicFireBall->m_CastTarget = CT_Enemy;
	MagicFireBall->m_CastEffect	= CE_DownHP;
	MagicFireBall->m_CastRange = 2;
	MagicFireBall->m_EffectValue = 20;
	MagicFireBall->m_Detail = "使用火球攻击";
	MagicFireBall->m_CastingAnimationTarget = CAT_SelectedTarget;
	MagicFireBall->m_Animation = FireAnime;

	MagicHandler->PushMagic(MagicCure);
	MagicHandler->PushMagic(MagicFireBall);

	//--------------------------------------------------------------------------------------------

	cAnimation *AnimeWait = new cAnimation(m_Graphics);
	AnimeWait->BuildTextureQueue(1);
	AnimeWait->LoadTexture(0,"Data\\pic\\Character\\Doll_1.png",D3DCOLOR_RGBA(255,255,255,255));
	AnimeWait->BuildAnimeSorceQueue(1);
	AnimeWait->LoadAnimeSorce(0,0,0,0,60,75);
	//anime_wait->SetTransforColor(D3DCOLOR_RGBA(100,255,255,255));
	//anime_wait->SetZoom(2);

	cAnimation *AnimeMoveDown = new cAnimation(m_Graphics);
	AnimeMoveDown->BuildTextureQueue(1);
	AnimeMoveDown->LoadTexture(0,"Data\\pic\\Character\\Doll_1.png",D3DCOLOR_RGBA(255,255,255,255));
	AnimeMoveDown->BuildAnimeSorceQueue(4);
	AnimeMoveDown->LoadAnimeSorce(0,0,60*0,75*0,60,75);
	AnimeMoveDown->LoadAnimeSorce(1,0,60*1,75*0,60,75);
	AnimeMoveDown->LoadAnimeSorce(2,0,60*2,75*0,60,75);
	AnimeMoveDown->LoadAnimeSorce(3,0,60*3,75*0,60,75);

	cAnimation *AnimeMoveUp = new cAnimation(m_Graphics);
	AnimeMoveUp->BuildTextureQueue(1);
	AnimeMoveUp->LoadTexture(0,"Data\\pic\\Character\\Doll_1.png",D3DCOLOR_RGBA(255,255,255,255));
	AnimeMoveUp->BuildAnimeSorceQueue(4);
	AnimeMoveUp->LoadAnimeSorce(0,0,60*0,75*3,60,75);
	AnimeMoveUp->LoadAnimeSorce(1,0,60*1,75*3,60,75);
	AnimeMoveUp->LoadAnimeSorce(2,0,60*2,75*3,60,75);
	AnimeMoveUp->LoadAnimeSorce(3,0,60*3,75*3,60,75);

	cAnimation *AnimeMoveLeft = new cAnimation(m_Graphics);
	AnimeMoveLeft->BuildTextureQueue(1);
	AnimeMoveLeft->LoadTexture(0,"Data\\pic\\Character\\Doll_1.png",D3DCOLOR_RGBA(255,255,255,255));
	AnimeMoveLeft->BuildAnimeSorceQueue(4);
	AnimeMoveLeft->LoadAnimeSorce(0,0,60*0,75*1,60,75);
	AnimeMoveLeft->LoadAnimeSorce(1,0,60*1,75*1,60,75);
	AnimeMoveLeft->LoadAnimeSorce(2,0,60*2,75*1,60,75);
	AnimeMoveLeft->LoadAnimeSorce(3,0,60*3,75*1,60,75);

	cAnimation *AnimeMoveRight = new cAnimation(m_Graphics);
	AnimeMoveRight->BuildTextureQueue(1);
	AnimeMoveRight->LoadTexture(0,"Data\\pic\\Character\\Doll_1.png",D3DCOLOR_RGBA(255,255,255,255));
	AnimeMoveRight->BuildAnimeSorceQueue(4);
	AnimeMoveRight->LoadAnimeSorce(0,0,60*0,75*2,60,75);
	AnimeMoveRight->LoadAnimeSorce(1,0,60*1,75*2,60,75);
	AnimeMoveRight->LoadAnimeSorce(2,0,60*2,75*2,60,75);
	AnimeMoveRight->LoadAnimeSorce(3,0,60*3,75*2,60,75);
	//anime_move->SetAdjustTime(200);

	cFightAnimation *AnimeFight = new cFightAnimation(m_Graphics);
	AnimeFight->BuildTextureQueue(1);
	AnimeFight->LoadTexture(0,"Data\\pic\\FightScene\\公主Mix.png",0);
	AnimeFight->BuildAnimeSorceQueue(15);
	int xishu  = 15;
	AnimeFight->LoadAnimeSorce(0,0,160*0,160*0,160,160,2000);
	AnimeFight->LoadAnimeSorce(1,0,160*1,160*0,160,160,5*xishu);
	AnimeFight->LoadAnimeSorce(2,0,160*2,160*0,160,160,2*xishu);
	AnimeFight->LoadAnimeSorce(3,0,160*3,160*0,160,160,12*xishu);
	AnimeFight->LoadAnimeSorce(4,0,160*0,160*1,160,160,4*xishu);
	AnimeFight->LoadAnimeSorce(5,0,160*1,160*1,160,160,4*xishu);
	AnimeFight->LoadAnimeSorce(6,0,160*2,160*1,160,160,7*xishu);
	AnimeFight->LoadAnimeSorce(7,0,160*3,160*1,160,160,7*xishu);
	AnimeFight->LoadAnimeSorce(8,0,160*0,160*2,160,160,20*xishu);
	AnimeFight->PushFightTrigger(8,0,FIGHT_ANIME_MESSAGE_Hit);
	AnimeFight->LoadAnimeSorce(9,0,160*1,160*2,160,160,3*xishu);
	AnimeFight->LoadAnimeSorce(10,0,160*2,160*2,160,160,2*xishu);
	AnimeFight->LoadAnimeSorce(11,0,160*3,160*2,160,160,2*xishu);
	AnimeFight->LoadAnimeSorce(12,0,160*0,160*3,160,160,3*xishu);
	AnimeFight->LoadAnimeSorce(13,0,160*1,160*3,160,160,2*xishu);
	AnimeFight->LoadAnimeSorce(14,0,160*2,160*3,160,160,3*xishu);
	//AnimeFight->SetIsReverseX(true);
	//anime_fight->SetAdjustTime(120);

	cFightAnimation *AnimeDefend = new cFightAnimation(m_Graphics);
	AnimeDefend->BuildTextureQueue(1);
	AnimeDefend->LoadTexture(0,"Data\\pic\\FightScene\\公主Mix.png",0);
	AnimeDefend->BuildAnimeSorceQueue(1);
	AnimeDefend->LoadAnimeSorce(0,0,160*0,160*0,160,160,2000);
	AnimeDefend->SetIfReverseX(true);

	cFightAnimation *AnimeStandby = new cFightAnimation(m_Graphics);
	AnimeStandby->BuildTextureQueue(1);
	AnimeStandby->LoadTexture(0,"Data\\pic\\FightScene\\公主Mix.png",0);
	AnimeStandby->BuildAnimeSorceQueue(1);
	AnimeStandby->LoadAnimeSorce(0,0,160*0,160*0,160,160,2000);

	cAnimation *AnimeFace = new cAnimation(m_Graphics);
	AnimeFace->BuildTextureQueue(1);
	AnimeFace->LoadTexture(0,"Data\\pic\\CharacterFace\\char1.bmp",D3DCOLOR_RGBA(255,255,255,255));
	AnimeFace->BuildAnimeSorceQueue(1);
	AnimeFace->LoadAnimeSorce(0,0,0,0,128,128);

	cAnimation *ShellNormal = new cAnimation(m_Graphics);
	ShellNormal->BuildTextureQueue(1);
	ShellNormal->LoadTexture(0,"Data\\pic\\Dialog\\人物对话用图片\\男一号\\M1_普通.BMP",D3DCOLOR_XRGB(32,32,32));
	ShellNormal->BuildAnimeSorceQueue(1);
	ShellNormal->LoadAnimeSorce(0,0,0,0,256,256);
	//ShellNormal->SetAlphaTransColour(D3DCOLOR_RGBA(255,255,255,255));

	cAnimation *ShellSmail = new cAnimation(m_Graphics);
	ShellSmail->BuildTextureQueue(1);
	ShellSmail->LoadTexture(0,"Data\\pic\\Dialog\\人物对话用图片\\男一号\\M1_微笑.BMP",D3DCOLOR_XRGB(32,32,32));
	ShellSmail->BuildAnimeSorceQueue(1);
	ShellSmail->LoadAnimeSorce(0,0,0,0,256,256);

	cMyCharacter* CharacterOne = new cMyCharacter(m_InfoUnion,m_Graphics,"魔王");
	CharacterOne->LoadMapAnime(CHAR_MAP_ANIME_Standby,AnimeWait);
	CharacterOne->LoadMapAnime(CHAR_MAP_ANIME_MovingDown,AnimeMoveDown);
	CharacterOne->LoadMapAnime(CHAR_MAP_ANIME_MovingUp,AnimeMoveUp);
	CharacterOne->LoadMapAnime(CHAR_MAP_ANIME_MovingLeft,AnimeMoveLeft);
	CharacterOne->LoadMapAnime(CHAR_MAP_ANIME_MovingRight,AnimeMoveRight);
	CharacterOne->LoadFightAnime(CHAR_FIGHT_ANIME_Attack,AnimeFight);
	CharacterOne->LoadFightAnime(CHAR_FIGHT_ANIME_Defend,AnimeDefend);
	CharacterOne->LoadFightAnime(CHAR_FIGHT_ANIME_Standby,AnimeStandby);
	CharacterOne->SetMyFace(AnimeFace);
	CharacterOne->SetCharState(CHAR_STATE_Standby);
	CharacterOne->SetCharDir(CHAR_DIR_Down);
	CharacterOne->SetMatrixPosX(4);
	CharacterOne->SetMatrixPosY(3);
	CharacterOne->SetDataName("魔王");
	CharacterOne->SetCharacterType(CHAR_TYPE_PLAYER);
	CharacterOne->SetDataHP(9999);
	CharacterOne->SetDataMaxHP(9999);
	CharacterOne->SetDataPower(1);
	CharacterOne->SetDataAttribute("圣");
	CharacterOne->SetDataMoveRange(5);
	CharacterOne->SetDataAttackRange(2);
	CharacterOne->PushMagic("治疗术");
	CharacterOne->PushMagic("火球术");
	CharacterOne->SetDialogShell(CShell_Normal,ShellNormal);
	CharacterOne->SetDialogShell(CShell_Smail,ShellSmail);
	CharacterOne->SetIfShow(true);

	m_SceneFormula->GetCharacterHandler()->AddCharacterToMatrix(CharacterOne);
	//-----------------------------------------------------------------------------------------------
	cAnimation *AnimeWaitAnother = new cAnimation(m_Graphics);
	AnimeWaitAnother->BuildTextureQueue(10);
	AnimeWaitAnother->LoadTexture(0,"Data\\pic\\unit_40_40\\Wait_LD00.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(1,"Data\\pic\\unit_40_40\\Wait_LD01.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(2,"Data\\pic\\unit_40_40\\Wait_LD02.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(3,"Data\\pic\\unit_40_40\\Wait_LD03.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(4,"Data\\pic\\unit_40_40\\Wait_LD04.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(5,"Data\\pic\\unit_40_40\\Wait_LD05.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(6,"Data\\pic\\unit_40_40\\Wait_LD06.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(7,"Data\\pic\\unit_40_40\\Wait_LD07.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(8,"Data\\pic\\unit_40_40\\Wait_LD08.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->LoadTexture(9,"Data\\pic\\unit_40_40\\Wait_LD09.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeWaitAnother->BuildAnimeSorceQueue(10);
	AnimeWaitAnother->LoadAnimeSorce(0,0,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(1,1,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(2,2,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(3,3,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(4,4,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(5,5,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(6,6,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(7,7,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(8,8,0,0,40,40);
	AnimeWaitAnother->LoadAnimeSorce(9,9,0,0,40,40);
	//anime_wait_another->SetTransforColor(D3DCOLOR_RGBA(100,255,255,255));
	//anime_wait_another->SetZoom(2);

	cAnimation *AnimeMoveAnother = new cAnimation(m_Graphics);
	AnimeMoveAnother->BuildTextureQueue(6);
	AnimeMoveAnother->LoadTexture(0,"Data\\pic\\unit_40_40\\Move_LD00.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->LoadTexture(1,"Data\\pic\\unit_40_40\\Move_LD01.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->LoadTexture(2,"Data\\pic\\unit_40_40\\Move_LD02.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->LoadTexture(3,"Data\\pic\\unit_40_40\\Move_LD03.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->LoadTexture(4,"Data\\pic\\unit_40_40\\Move_LD04.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->LoadTexture(5,"Data\\pic\\unit_40_40\\Move_LD05.bmp",D3DCOLOR_RGBA(104,104,104,255));
	AnimeMoveAnother->BuildAnimeSorceQueue(6);
	AnimeMoveAnother->LoadAnimeSorce(0,0,0,0,40,40);
	AnimeMoveAnother->LoadAnimeSorce(1,1,0,0,40,40);
	AnimeMoveAnother->LoadAnimeSorce(2,2,0,0,40,40);
	AnimeMoveAnother->LoadAnimeSorce(3,3,0,0,40,40);
	AnimeMoveAnother->LoadAnimeSorce(4,4,0,0,40,40);
	AnimeMoveAnother->LoadAnimeSorce(5,5,0,0,40,40);

	cFightAnimation *AnimeFightAnother = new cFightAnimation(m_Graphics);
	AnimeFightAnother->BuildTextureQueue(1);
	AnimeFightAnother->LoadTexture(0,"Data\\pic\\FightScene\\骑士Mix.png",0);
	AnimeFightAnother->BuildAnimeSorceQueue(26);
	AnimeFightAnother->LoadAnimeSorce(0,0,320*0,240*0,320,240,xishu*28,0,60);
	AnimeFightAnother->LoadAnimeSorce(1,0,320*1,240*0,320,240,xishu*10,0,60);
	AnimeFightAnother->LoadAnimeSorce(2,0,320*2,240*0,320,240,xishu*7,0,60);
	AnimeFightAnother->LoadAnimeSorce(3,0,320*3,240*0,320,240,xishu*7,0,60);
	AnimeFightAnother->LoadAnimeSorce(4,0,320*4,240*0,320,240,xishu*16,0,60);
	AnimeFightAnother->LoadAnimeSorce(5,0,320*0,240*1,320,240,xishu*5,0,60);
	AnimeFightAnother->LoadAnimeSorce(6,0,320*1,240*1,320,240,xishu*11,0,60);
	AnimeFightAnother->LoadAnimeSorce(7,0,320*2,240*1,320,240,xishu*50,0,60);
	AnimeFightAnother->PushFightTrigger(7,0,FIGHT_ANIME_MESSAGE_Hit);
	AnimeFightAnother->LoadAnimeSorce(8,0,320*3,240*1,320,240,xishu*3,0,60);
	AnimeFightAnother->LoadAnimeSorce(9,0,320*4,240*1,320,240,xishu*2,0,60);
	AnimeFightAnother->LoadAnimeSorce(10,0,320*0,240*2,320,240,xishu*2,0,60);
	AnimeFightAnother->LoadAnimeSorce(11,0,320*1,240*2,320,240,xishu*4,0,60);
	AnimeFightAnother->LoadAnimeSorce(12,0,320*2,240*2,320,240,xishu*6,0,60);
	AnimeFightAnother->LoadAnimeSorce(13,0,320*3,240*2,320,240,xishu*2,0,60);
	AnimeFightAnother->LoadAnimeSorce(14,0,320*4,240*2,320,240,xishu*2,0,60);
	AnimeFightAnother->LoadAnimeSorce(15,0,320*0,240*3,320,240,xishu*7,0,60);
	AnimeFightAnother->LoadAnimeSorce(16,0,320*1,240*3,320,240,xishu*2,0,60);
	AnimeFightAnother->LoadAnimeSorce(17,0,320*2,240*3,320,240,xishu*3,0,60);
	AnimeFightAnother->LoadAnimeSorce(18,0,320*3,240*3,320,240,xishu*3,0,60);
	AnimeFightAnother->LoadAnimeSorce(19,0,320*4,240*3,320,240,xishu*5,0,60);
	AnimeFightAnother->LoadAnimeSorce(20,0,320*0,240*4,320,240,xishu*5,0,60);
	AnimeFightAnother->LoadAnimeSorce(21,0,320*1,240*4,320,240,xishu*5,0,60);
	AnimeFightAnother->LoadAnimeSorce(22,0,320*2,240*4,320,240,xishu*5,0,60);
	AnimeFightAnother->LoadAnimeSorce(23,0,320*3,240*4,320,240,xishu*8,0,60);
	AnimeFightAnother->LoadAnimeSorce(24,0,320*4,240*4,320,240,xishu*12,0,60);
	AnimeFightAnother->LoadAnimeSorce(25,0,320*0,240*5,320,240,xishu*7,0,60);


	cFightAnimation *AnimeDefendAnother = new cFightAnimation(m_Graphics);
	AnimeDefendAnother->BuildTextureQueue(1);
	AnimeDefendAnother->LoadTexture(0,"Data\\pic\\background\\Tiles.bmp",D3DCOLOR_RGBA(255,255,255,255));
	AnimeDefendAnother->BuildAnimeSorceQueue(4);
	AnimeDefendAnother->LoadAnimeSorce(0,0,0,0,64,64);
	AnimeDefendAnother->LoadAnimeSorce(1,0,64,0,64,64);
	AnimeDefendAnother->LoadAnimeSorce(2,0,128,0,64,64);
	AnimeDefendAnother->LoadAnimeSorce(3,0,192,0,64,64);

	cFightAnimation *AnimeStandbyAnother = new cFightAnimation(m_Graphics);
	AnimeStandbyAnother->BuildTextureQueue(1);
	AnimeStandbyAnother->LoadTexture(0,"Data\\pic\\background\\Tiles.bmp",D3DCOLOR_RGBA(255,255,255,255));
	AnimeStandbyAnother->BuildAnimeSorceQueue(4);
	AnimeStandbyAnother->LoadAnimeSorce(0,0,0,0,64,64);
	AnimeStandbyAnother->LoadAnimeSorce(1,0,64,0,64,64);
	AnimeStandbyAnother->LoadAnimeSorce(2,0,128,0,64,64);
	AnimeStandbyAnother->LoadAnimeSorce(3,0,192,0,64,64);

	cAnimation *AnimeFaceAnother = new cAnimation(m_Graphics);
	AnimeFaceAnother->BuildTextureQueue(1);
	AnimeFaceAnother->LoadTexture(0,"Data\\pic\\CharacterFace\\char2.bmp",D3DCOLOR_RGBA(255,255,255,255));
	AnimeFaceAnother->BuildAnimeSorceQueue(1);
	AnimeFaceAnother->LoadAnimeSorce(0,0,0,0,128,128);

	cAnimation *ShellNormalAnother = new cAnimation(m_Graphics);
	ShellNormalAnother->BuildTextureQueue(1);
	ShellNormalAnother->LoadTexture(0,"Data\\pic\\Dialog\\人物对话用图片\\女一号\\F1_普通.BMP",D3DCOLOR_XRGB(32,32,32));
	ShellNormalAnother->BuildAnimeSorceQueue(1);
	ShellNormalAnother->LoadAnimeSorce(0,0,0,0,256,256);

	cAnimation *ShellSmailAnother = new cAnimation(m_Graphics);
	ShellSmailAnother->BuildTextureQueue(1);
	ShellSmailAnother->LoadTexture(0,"Data\\pic\\Dialog\\人物对话用图片\\女一号\\F1_微笑.BMP",D3DCOLOR_XRGB(32,32,32));
	ShellSmailAnother->BuildAnimeSorceQueue(1);
	ShellSmailAnother->LoadAnimeSorce(0,0,0,0,256,256);

	cMyCharacter* CharacterTwo = new cMyCharacter(m_InfoUnion,m_Graphics,"BOSS");
	CharacterTwo->LoadMapAnime(CHAR_MAP_ANIME_Standby,AnimeWaitAnother);
	//CharacterTwo->LoadAnime(CHAR_STATE_Move,AnimeMoveAnother);
	CharacterTwo->LoadFightAnime(CHAR_FIGHT_ANIME_Attack,AnimeFightAnother);
	CharacterTwo->LoadFightAnime(CHAR_FIGHT_ANIME_Defend,AnimeDefendAnother);
	CharacterTwo->LoadFightAnime(CHAR_FIGHT_ANIME_Standby,AnimeStandbyAnother);
	CharacterTwo->SetMyFace(AnimeFaceAnother);
	CharacterTwo->SetCharState(CHAR_STATE_Standby);
	CharacterTwo->SetCharDir(CHAR_DIR_Down);
	CharacterTwo->SetMatrixPosX(5);
	CharacterTwo->SetMatrixPosY(4);
	CharacterTwo->SetDataName("BOSS");
	CharacterTwo->SetCharacterType(CHAR_TYPE_NPC);
	CharacterTwo->SetDataHP(10);
	CharacterTwo->SetDataMaxHP(10);
	CharacterTwo->SetDataPower(1);
	CharacterTwo->SetDataAttribute("暗");
	CharacterTwo->SetDataMoveRange(3);
	CharacterTwo->SetDataAttackRange(1);
	CharacterTwo->PushOrderAI(0,AC_HPMore90Percent,AB_MoveAndAttak);
	CharacterTwo->PushOrderAI(1,AC_HPMore80Percent,AB_MoveUpOneStep);
	CharacterTwo->SetDialogShell(CShell_Normal,ShellNormalAnother);
	CharacterTwo->SetDialogShell(CShell_Smail,ShellSmailAnother);
	CharacterTwo->SetIfShow(true);

	m_SceneFormula->GetCharacterHandler()->AddCharacterToMatrix(CharacterTwo);

	//-----------------------------------------------------------------------------------------------

	m_SceneFormula->m_MatrixLine->SetColour(D3DCOLOR_RGBA(200,100,200,0));
	m_SceneFormula->m_MatrixLine->TurnOn();

	//---------------------------------------------------------------------------------------------------
	cAnimation *RangeAnime = new cAnimation(m_Graphics);
	RangeAnime->BuildTextureQueue(2);
	RangeAnime->LoadTexture(0,"Data\\pic\\move_range_colour\\flag1_1.bmp",D3DCOLOR_RGBA(129,129,129,255));
	RangeAnime->LoadTexture(1,"Data\\pic\\move_range_colour\\flag1_2.bmp",D3DCOLOR_RGBA(129,129,129,255));
	RangeAnime->BuildAnimeSorceQueue(2);
	RangeAnime->LoadAnimeSorce(0,0,0,0,40,40);
	RangeAnime->LoadAnimeSorce(1,1,0,0,40,40);
	RangeAnime->SetAlphaTransColour(D3DCOLOR_RGBA(255,255,255,128));
	RangeAnime->SetAdjustTime(500);

	m_SceneFormula->m_RangeHoney->SetRangeAnime(RangeAnime);
	m_SceneFormula->m_RangeHoney->SetIfShow(false);

	//------------------------------------------------------------------------------------------------

	m_SceneFormula->m_CharacterDialog->SetIfShow(false);

	//-------------------------------------------------------------------------------------------------

	//设置游标为焦点
	m_SceneFormula->m_FocusReceiver = m_SceneFormula->m_Cursor;

///////////////////////////////////////////////////////////////////////////////////////////////////////////
//分界线
//////////////////////////////////////////////////////////////////////////////////////////////////////////

	m_BehaviorHandler->BehDefBegin();
	m_BehaviorHandler->BehDefFlag("new demo");
	m_BehaviorHandler->BehDefAction(new ProcLockInputSF());
	m_BehaviorHandler->BehDefAction(new ProcCharDialogProgram(
		"魔王\%左边\%普通\%hello\
		|BOSS\%右边\%微笑\%你好\
		|魔王\%左边\%微笑\%美女,你好啊\
		|BOSS\%右边\%普通\%真讨厌,我好不好关你什么事啊\
		|魔王\%左边\%微笑\%你讨厌我吗?\
		|BOSS\%右边\%普通\%那还用说"
		));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcSetCharacterIfShow("魔王",false));
	m_BehaviorHandler->BehDefAction(new ProcSetCharacterIfShow("BOSS",false));
	m_BehaviorHandler->BehDefAction(new ProcSetCursorIfShow(false));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcMsgDialogShowAndWait(
		"今天是星期4\
		|游戏的目标是干掉\n自己唯一的镜像\
		|这个游戏甚至还\n没有AI,所以敌人是\n认人蹂躏的\
		|那么,开始吧"
		));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcPutCharacterTo("魔王",2,5));
	m_BehaviorHandler->BehDefAction(new ProcSetCharacterIfShow("魔王",true));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcSetMessageDialogSrcPos(150,100));
	m_BehaviorHandler->BehDefAction(new ProcMsgDialogShowAndWait(
		"主角就这样很\n不气派地登场了...\n连个声音都没有"));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcPutCharacterTo("BOSS",8,9));
	m_BehaviorHandler->BehDefAction(new ProcSetCharacterIfShow("BOSS",true));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcMsgDialogShowAndWait(
		"敌人也登场了,不过可能\n你还看不见可以通\n过卷轴找到敌人\|那么,战斗开始..."));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcSetCursorIfShow(true));
	m_BehaviorHandler->BehDefAction(new ProcUnlockInputSF());
	m_BehaviorHandler->BehDefFinish();


	m_BehaviorHandler->BehDefBegin();
	m_BehaviorHandler->BehDefFlag("step count");
	m_BehaviorHandler->BehDefRuleStart(new JudgeCursorMoveStep(5));
	m_BehaviorHandler->BehDefAction(new ProcLockInputSF());
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	m_BehaviorHandler->BehDefAction(new ProcCharDialogProgram("魔王\%左边\%微笑\%游标已经移动5次了\n我来玩点小花样"));
	m_BehaviorHandler->BehDefActionLinkType(ACTION_THEN);
	//m_BehaviorHandler->BehDefAction(new ProcRandomMapData(100,5000));
	m_BehaviorHandler->BehDefAction(new ProcUnlockInputSF());
	//m_ActionManager->BehDefRuleEnd(new JudgeTimePass(3000));
	m_BehaviorHandler->BehDefFinish();


	//执行以下行为
	m_BehaviorHandler->BehMakeDeal("new demo");
	m_BehaviorHandler->BehMakeDeal("step count");

	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("New Script");
	//m_ActionManager->BehDefAction(new ProcSetCameraPosition(100,100));
	//m_ActionManager->BehDefAction(new ProcSetMapIfShow(false));
	//m_ActionManager->BehDefAction(new ProcSetCharacterIfShow("CharOne",false));
	//m_ActionManager->BehDefAction(new ProcSetCharacterIfShow("CharTwo",false));
	//m_ActionManager->BehDefAction(new ProcSetCursorIfShow(false));
	//m_ActionManager->BehDefAction(new ProcSetMatrixLineIfShow(false));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(3000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcMessageDialog("现在是一片黑夜\|我等待时间的结束"));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(3000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcMessageDialog("我来唤醒第一个角色"));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(1000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcSetCharacterIfShow("CharOne",true));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(1000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcSetMapIfShow(true));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(1000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcSetCameraPosition(50,50));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcMoveCharacterMatrixTo("CharOne",10,10));
	//m_ActionManager->BehDefAction(new ProcSetCameraPosition(200,200));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehMakeDeal("New Script");
//--------------------------------------------------------------------------------------------------------

	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("buildWinAndMoveAndKill");
	//m_ActionManager->BehDefRuleStart(NULL);
	//m_ActionManager->BehDefInit(new ProcBuildWin("love"));
	//m_ActionManager->BehDefInit(new ProcPutWinTo("love",0,0));
	//m_ActionManager->BehDefInit(new ProcBuildWin("loveless"));
	//m_ActionManager->BehDefInit(new ProcPutWinTo("loveless",50,0));
	//m_ActionManager->BehDefAction(new ProcMoveWin("love",200,200,1,5));
	//m_ActionManager->BehDefAction(new ProcMoveWin("loveless",450,250,1,5));
	////m_ActionManager->BehDefRuleEnd(new JudgeWinCooX("love",300));
	////m_ActionManager->BehDefRuleEnd(new JudgeWinCooY("love",300));
	//m_ActionManager->BehDefActionAfterEnd(new ProcKillWin("love"));
	//m_ActionManager->BehDefActionAfterEnd(new ProcKillWin("loveless"));
	//m_ActionManager->BehDefActionAfterEnd(new RunBehavior("buildWinAndMoveAndKill"));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehMakeDealSuper("buildWinAndMoveAndKill");
	//m_ActionManager->BehMakeDeal("buildWinAndMoveAndKill");

	//this->m_ActionManager->PushQuickProc( new ProcBuildWin("mywindow3",0,100,20,50,GREEN_COLOR) );
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("NanaMove1");
	//m_ActionManager->BehDefRuleStart(NULL);
	//m_ActionManager->BehDefInit(new ProcLockPlayerControl());
	//m_ActionManager->BehDefInit(new ProcPutCharacterTo("CharTwo",1,6));
	//m_ActionManager->BehDefAction(new ProcMoveCharacterTo("CharTwo",10,2));
	//m_ActionManager->BehDefActionAfterEnd(new ProcUnlockPlayerControl());
	////m_ActionManager->BehDefActionAfterEnd(new RunBehavior("NanaMove2"));
	//m_ActionManager->BehDefFinish();


	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("NanaMove2");
	//m_ActionManager->BehDefRuleStart(NULL);
	//m_ActionManager->BehDefInit(new ProcLockPlayerControl());
	//m_ActionManager->BehDefInit(new ProcPutCharacterTo("CharOne",10,2));
	//m_ActionManager->BehDefAction(new ProcMoveCharacterTo("CharOne",1,6));
	//m_ActionManager->BehDefActionAfterEnd(new ProcUnlockPlayerControl());
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehMakeDeal("NanaMove1");
	//m_ActionManager->BehMakeDeal("NanaMove2");


	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("newNanaMove");
	//m_ActionManager->BehDefRuleStart(NULL);
	//m_ActionManager->BehDefInit(new ProcLockPlayerControl());
	//m_ActionManager->BehDefInit(new ProcPutCharacterTo("CharTwo",1,6));
	//m_ActionManager->BehDefInit(new ProcPutCharacterTo("CharOne",10,2));

	//m_ActionManager->BehDefAction(new ProcMessageDialog("在遥远的过去\|发生了一件事情\|那是~~~"));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcMoveCharacterTo("CharTwo",10,2));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcDelay(1000));
	//m_ActionManager->BehDefActionLinkType(ACTION_THEN);
	//m_ActionManager->BehDefAction(new ProcMoveCharacterTo("CharOne",1,6));

	//m_ActionManager->BehDefActionAfterEnd(new ProcUnlockPlayerControl());
	//m_ActionManager->BehDefFinish();


	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("NanaTrigger");
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixX("CharTwo",2,COMPARE_EQUAL));
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixY("CharTwo",1,COMPARE_EQUAL));
	//m_ActionManager->BehDefInit( NULL );
	//m_ActionManager->BehDefAction(new RunBehavior("newNanaMove"));
	//m_ActionManager->BehDefFinish();


	//m_ActionManager->BehMakeDeal("NanaTrigger");

	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("Delay");
	//m_ActionManager->BehDefRuleStart(NULL);
	//m_ActionManager->BehDefAction(new ProcDelay(5000));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehDefUnionBegin();
	//m_ActionManager->BehDefUnionFlag("NanaMove1+2");
	//m_ActionManager->BehDefUnionRule("NanaMove1");
	//m_ActionManager->BehDefUnionRule("Delay");
	//m_ActionManager->BehDefUnionRule("NanaMove2");
	//m_ActionManager->BehDefUnionFinish();

	//m_ActionManager->BehUnionMakeDeal("NanaMove1+2");

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("TouchAndMoveCharactor");
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixX("CharOne",2,COMPARE_EQUAL));
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixY("CharOne",1,COMPARE_EQUAL));
	//m_ActionManager->BehDefInit(NULL);
	//m_ActionManager->BehDefAction(new ProcPutCharacterTo("CharOne",5,5));
	//m_ActionManager->BehDefActionAfterEnd(new RunBehavior("TouchAndMoveCharactor"));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehMakeDeal("TouchAndMoveCharactor");

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("TouchAndTalk");
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixX("CharOne",2,COMPARE_EQUAL));
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixY("CharOne",2,COMPARE_EQUAL));
	//m_ActionManager->BehDefInit( new ProcSetSceneFormulaControlState(false) );
	//m_ActionManager->BehDefInit( new ProcSetCharacterDialogShow(true) );
	//m_ActionManager->BehDefAction(new ProcCharactorTalk("CharOne","hello world"));
	//m_ActionManager->BehDefActionAfterEnd( new ProcSetSceneFormulaControlState(true) );
	//m_ActionManager->BehDefActionAfterEnd( new ProcSetCharacterDialogShow(false) );
	//m_ActionManager->BehDefActionAfterEnd(new RunBehavior("LeaveAndTrigger"));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehDefBegin();
	//m_ActionManager->BehDefFlag("LeaveAndTrigger");
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixX("CharOne",2,COMPARE_NOTEQUAL));
	//m_ActionManager->BehDefRuleStart(new JudgeCharactorMatrixY("CharOne",2,COMPARE_NOTEQUAL),LINK_OR);
	//m_ActionManager->BehDefAction(new RunBehavior("TouchAndTalk"));
	////m_ActionManager->BehDefActionAfterEnd(new RunBehavior("TouchAndTalk"));
	//m_ActionManager->BehDefFinish();

	//m_ActionManager->BehMakeDeal("TouchAndTalk");
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return true;
}

bool cMySystem::Render()
{
	//DWORD curtime=timeGetTime();
	//if(curtime-m_lasttime<m_rtime)
	//{
	//	//Sleep(10);//睡眠
	//	return true;
	//}
	//else
	//{
	//	//cout<<"time: "<<curtime-m_lasttime<<endl;
	//	this->m_lasttime=curtime;
	//	
	//}
	
	if( NULL == m_Graphics->GetDeviceCOM())
	{
		return false;
	}

	m_Graphics->Clear( D3DCOLOR_XRGB(0,0,0) );

	// 顺序已经变得很重要,m_SceneFormula需要在最前面是因为m_MessageRecorder放在最后面
	this->m_SceneFormula->DoProcess();
	this->m_BehaviorHandler->DoProcess();//action process
	this->m_Trigger->DoProcess();//trigger process
	this->m_ProcessEngine->DoProcess();//..............
	
	m_MessageRecorder->RefreshRecords();//	用在最后
	
	

	m_SceneFormula->ObjectsRender();
	// 开始绘制
	m_DrawMaster->DrawObjects();

	// 清除绘制对象
	//m_DrawMaster->CleanDrawObjects();
	//m_MyWindow->DrawWindowB();

	//end of scene
	//m_Graphics->EndScene();

    // Present the back buffer contents to the display
	m_Graphics->Display();
	
	//cout<<"fps cost time: "<<timeGetTime()-m_lasttime<<endl;//debug
	return true;
}

//开发中
bool cMySystem::ControlCenter()
{

	return true;
}

bool cMySystem::SetFPS(float fps)
{
	if(fps<=0)
	{
		cout<<"error!FPS can't be 0 or below 0"<<endl;//debug
		return false;
	}
	this->m_FTime=1000/fps;

	return true;
}
